﻿@model KRM.Core.tblKRMRSDispute
@{
    ViewBag.Title = "New Rdm Order";
    Layout = "~/Views/Shared/_Layout.cshtml";
    var orderItem = Model.OrderItem;
}
<script type="text/javascript">
    window.onbeforeunload = confirmExit;
    function confirmExit() {
        $.ajax({            
            url: "/rdm/updatewaitingallocated?orderid=" + $("#hforderid").val()
        });
        return "";
    }
</script>
<div class="container-fluid">
    <div class="page-header"></div>
    <input type="hidden" id="hfdisputeid" value="@Model.DisputeID"/>
    <div class="row-fluid">
        <div class="span1">RDM</div>
        <div class="span1">@Model.DisputeID</div>
        <div class="span10 text-right">
            <button class="btn btn-primary btn-createrdmorder" onclick="createrdmorder(@Model.DisputeID);">Create RDM Order</button>
        </div>
    </div>

    <fieldset>
        <legend>Original Order Info</legend>
        <div class="row-fluid">
            <div class="span3">
                <div class="row-fluid">
                    <div class="span5">
                        Order ref
                    </div>
                    <div class="span7">
                        <input type="text" class="input-block-level" readonly="readonly" value="@orderItem.Order.OrderRef"/>
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span5">
                        RDM Action
                    </div>
                    <div class="span7">
                        <input type="text" class="input-block-level" readonly="readonly" value="@(Model.DisputeAction != null ? Model.DisputeAction.Action : "")" />
                    </div>
                </div>
            </div>
            <div class="span7 row-fluid">
                <div class="span2">
                    Order item
                </div>
                <div class="span10">
                    <textarea class="input-block-level" rows="3" readonly="readonly">@(orderItem.OrderItemID + " - " + orderItem.ProductName + Environment.NewLine +
                                                                                       orderItem.ProductOption + Environment.NewLine +
                                                                                       orderItem.ProductSubOptions)</textarea>
                </div>
            </div>
            <div class="span2">
                <a href="/orderview/orderdetail?orderref=@orderItem.Order.OrderRef" target="_blank" class="btn btn-primary">Show Original Order</a>
            </div>
        </div>
        <div class="row-fluid">
            <div class="span6">
                <div class="row-fluid">
                    <div class="span4">
                        Collection Items
                    </div>
                    <div class="span8">
                        <textarea class="input-block-level" readonly="readonly">@Model.ApprovedCollectionItems</textarea>
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span4">
                        Replacement Items
                    </div>
                    <div class="span8">
                        <textarea class="input-block-level" readonly="readonly">@Model.ApprovedReplacementItems</textarea>
                    </div>
                </div>
            </div>
            <div class="span6">
                <div class="row-fluid">
                    <div class="span4">
                        Futher Details
                    </div>
                    <div class="span8">
                        <textarea class="input-block-level" rows="5" readonly="readonly">@Model.Description</textarea>
                    </div>
                </div>
            </div>
        </div>
    </fieldset>
    <div class="createrdmorder-loading"></div>
    <div class="createrdmorder">
        <fieldset>
            <legend>RDM Order</legend>
            <div class="fr-saverdmorder-loading"></div>
            <form action="/rdm/saverdmorder" method="POST" class="margin0 fr-saverdmorder">
                <input type="hidden" name="orderid" id="orderid" />
                <div class="row-fluid">
                    <div class="span2">Orderref</div>
                    <div class="span3">
                        <input type="text" name="orderref" class="input-block-level" id="orderref" />
                    </div>
                    <div class="span7 text-right">
                        <a class="btn btn-primary" id="btn-selectdate-rdmorder" onclick="">Select delivery date</a>
                        <a href="/orderview/orderdetail?orderref=@orderItem.Order.OrderRef" target="_blank" class="btn btn-primary btn-showrdmorder">Show RDM Order</a>
                        <button type="submit" class="btn btn-primary" style="margin-left: 10px">Save</button>
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span2">Special Instruction</div>
                    <div class="span10">
                        <textarea class="input-block-level" rows="3" id="specialinstruction" name="specialinstruction"></textarea>
                    </div>
                </div>
            </form>
        </fieldset>
        <div class="row-fluid">
            <form action="/rdm/createorderitem" method="POST" class="margin0 fr-createorderitem span6">
                <input type="hidden" name="bFullitem" value="@(Model.ActionID == 2 || Model.ActionID == 3 ? "True" : "False")" />
                <input type="hidden" name="disputeid" value="@Model.DisputeID" />
                <input type="hidden" name="orderid" id="hforderid" />
                <div class="row-fluid">
                    <div class="span4">
                        <button class="btn btn-primary">Create Order Item</button>
                    </div>
                    <div class="span8">
                        <label style="margin-right: 15px" class="pull-left">
                            <input type="radio" name="action" value="Collection" class="pull-left" style="margin-right: 5px" />
                            Collection
                        </label>
                        <label style="margin-right: 15px" class="pull-left">
                            <input type="radio" name="action" value="Replacement" class="pull-left" style="margin-right: 5px" />
                            Replacement
                        </label>
                        <label style="margin-right: 15px" class="pull-left">
                            <input type="radio" name="action" value="Spare" class="pull-left" style="margin-right: 5px" checked="checked" />
                            Spare
                        </label>
                    </div>
                </div>
            </form>
            <div class="span6 text-right">
                @*@if (Model.ActionID == 2 || Model.ActionID == 3)
                {
                    <button type="submit" class="btn btn-primary" style="margin-left: 10px">Add Associated Parts</button>
                <button type="submit" class="btn btn-primary btn-editpart" style="margin-left: 10px">Edit Part</button>
                }*@
                <button type="button" class="btn btn-primary btn-allocateparts" style="margin-left: 10px">Allocate Parts</button>
            </div>
        </div>
        <div class="row-fluid" style="margin: 10px 0">
            <div class="span6">
                Order Item
                <div style="height: 200px; overflow: auto" class="pn-orderitem">
                    <table class="table table-bordered table-fix">
                        <thead>
                            <tr>
                                <th>OrderItemId</th>
                                <th>ProductName</th>
                                <th>ProductOption</th>
                            </tr>
                        </thead>
                    </table>
                </div>
            </div>
            <div class="span6">
                Parts
                <div style="height: 200px; overflow: auto" class="pn-orderitempart">
                    <table class="table table-bordered table-fix">
                        <thead>
                            <tr>
                                <th>LoadItemStatus</th>
                                <th>Delivery Type</th>
                                <th>PartQuantity</th>
                                <th>PartName</th>
                                <th>TradeCost</th>
                                <th>FromStock</th>
                                <th>StockPicked</th>
                                <th>StockSent</th>
                                <th>StockHeld</th>
                                <th>Warehouse</th>
                                <th>WaitingForStock</th>
                                <th>StockInDate</th>
                                <th>DatePicked</th>
                                <th>DateSent</th>
                                <th>IsStocked</th>
                                <th>Invoiced</th>
                                <th>StockAllocatedDate</th>
                                <th>PartID</th>
                                <th>OrderItemID</th>
                                <th>CustomerWaitingForPartID</th>
                                <th>WarehouseOnlyService</th>
                                <th>ItemCancelled</th>
                                <th>Warehouse</th>
                                <th>ProductCode</th>
                                <th>CarrierService</th>
                                <th>DelType</th>
                            </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>
        <form action="/rdm/saveorderitem" method="POST" class="fr-saveorderitem">
            <div class="row-fluid">
                <div class="span2">Product Name</div>
                <div class="span8">
                    <input type="text" class="input-block-level" />
                </div>
            </div>
            <div class="row-fluid">
                <div class="span2">Product Option</div>
                <div class="span8">
                    <input type="text" class="input-block-level" />
                </div>
            </div>
            <div class="row-fluid">
                <div class="span2">Sub Options</div>
                <div class="span8">
                    <input type="text" class="input-block-level" />
                </div>
                <div class="span2">
                    <button type="button" class="btn btn-primary" style="margin-left: 10px">Save</button>
                </div>
            </div>
        </form>
    </div>
    <div class="text-right">
        <a href="/rdm/approverdms" class="btn">Back</a>
    </div>
</div>
